package com.yy.config;


import com.yy.intercepter.UserRequestIntercepter;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.DispatcherServlet;

@Configuration
@RequiredArgsConstructor
@ConditionalOnClass(DispatcherServlet.class)
//@ConditionalOnProperty(name = "mvc-config.enabled", havingValue = "true")
//@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)

public class SpringMvcConfig implements org.springframework.web.servlet.config.annotation.WebMvcConfigurer {


    private final UserRequestIntercepter userRequestIntercepter;
    //注册拦截器
    @Override
    public void addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry registry) {
        registry.addInterceptor(userRequestIntercepter).addPathPatterns("/**");
    }

}
